package com.ruoyi.evalution.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.evalution.domain.LabEvalutionResult;
import com.ruoyi.evalution.service.ILabEvalutionResultService;

/**
 * 评测分数Controller
 * 
 * @author winner pan
 * @date 2022-04-15
 */
@RestController
@RequestMapping("/evalution/result")
public class LabEvalutionResultController extends BaseController {
	@Autowired
	private ILabEvalutionResultService labEvalutionResultService;

	/**
	 * 查询评测分数列表
	 */
	@PreAuthorize("@ss.hasPermi('evalution:labEvalution:query')")
	@GetMapping("/list")
	public TableDataInfo list(LabEvalutionResult labEvalutionResult) {
		startPage();
		List<LabEvalutionResult> list = labEvalutionResultService.selectLabEvalutionResultList(labEvalutionResult);
		return getDataTable(list);
	}

	/**
	 * 导出评测分数列表
	 */
	// @PreAuthorize("@ss.hasPermi('evalution:result:export')")
	/*
	 * @Log(title = "评测分数", businessType = BusinessType.EXPORT)
	 * 
	 * @GetMapping("/export") public AjaxResult export(LabEvalutionResult
	 * labEvalutionResult) { List<LabEvalutionResult> list =
	 * labEvalutionResultService.selectLabEvalutionResultList(labEvalutionResult
	 * ); ExcelUtil<LabEvalutionResult> util = new
	 * ExcelUtil<LabEvalutionResult>(LabEvalutionResult.class); return
	 * util.exportExcel(list, "result"); }
	 */

	/**
	 * 获取评测分数详细信息
	 */
	@PreAuthorize("@ss.hasPermi('evalution:labEvalution:query')")
	@GetMapping(value = "/{evalutionResultId}")
	public AjaxResult getInfo(@PathVariable("evalutionResultId") Long evalutionResultId) {
		return AjaxResult.success(labEvalutionResultService.selectLabEvalutionResultById(evalutionResultId));
	}

	/**
	 * 新增评测分数
	 */
	@PreAuthorize("@ss.hasPermi('evalution:labEvalution:edit')")
	@Log(title = "评测分数", businessType = BusinessType.INSERT)
	@PostMapping
	public AjaxResult add(@RequestBody LabEvalutionResult labEvalutionResult) {
		return toAjax(labEvalutionResultService.insertLabEvalutionResult(labEvalutionResult));
	}

	/**
	 * 修改评测分数
	 */
	@PreAuthorize("@ss.hasPermi('evalution:labEvalution:edit')")
	@Log(title = "评测分数", businessType = BusinessType.UPDATE)
	@PutMapping
	public AjaxResult edit(@RequestBody LabEvalutionResult labEvalutionResult) {
		return toAjax(labEvalutionResultService.updateLabEvalutionResult(labEvalutionResult));
	}

	/**
	 * 删除评测分数
	 */
	// @PreAuthorize("@ss.hasPermi('evalution:result:remove')")
	/*
	 * @Log(title = "评测分数", businessType = BusinessType.DELETE)
	 * 
	 * @DeleteMapping("/{evalutionResultIds}") public AjaxResult
	 * remove(@PathVariable Long[] evalutionResultIds) { return
	 * toAjax(labEvalutionResultService.deleteLabEvalutionResultByIds(
	 * evalutionResultIds)); }
	 */
}
